package com.tnf.bc.bground.common.utils.resultutil;


import java.io.Serializable;

/**
 * @description: //响应工具类
 * @author: lzl
 * @create: 2022-11-18 16:34
 **/
public class ApiResponse implements Serializable {

    private int code;
    private String message;
    private Object data;
    private boolean more;

    public ApiResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ApiResponse(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ApiResponse() {

        this.code = Status.SUCCESS.getCode();
        this.message = Status.SUCCESS.getStandardMessage();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public boolean isMore() {
        return more;
    }

    public void setMore(boolean more) {
        this.more = more;
    }

    public static ApiResponse ofMessage(int code, String message) {
        return new ApiResponse(code, message, null);
    }

    public static ApiResponse ofSuccess(Object data) {
        return new ApiResponse(Status.SUCCESS.getCode(), Status.SUCCESS.getStandardMessage(), data);
    }

    public static ApiResponse ofStatus(Status status) {
        return new ApiResponse(status.getCode(), status.getStandardMessage(), null);
    }

    public enum Status {

        SUCCESS(200, "OK"), BAD_REQUEST(400, "Bad Request"), INTERNAL_SERVER_ERROR(500,
                "Unknown Internal Error"), NOT_VALID_PARAM(40005,
                "Not valid Params"), NOT_SUPPORTED_OPERATION(4006, "Operation not supported"),
        NOTUSER(406, "用户名已存在"),
        PASSWORDRULESERORRONE(407, "密码需6-20位不能包含中文和指定特殊字符"),
        PASSWORDRULESERORRTWO(408, "密码必须是包含大写字母、小写字母、数字、特殊符号（#?!@$%^&*-.）的8位-16位的组合"),
        PASSWORDRULESERORRTHREE(409, "密码必须包含大写字母、小写字母、数字、特殊符号（#?!@$%^&*-.）4种类型的8位-16位的组合");




        private int code;
        private String standardMessage;

        Status(int code, String message) {
            this.code = code;
            this.standardMessage = message;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getStandardMessage() {
            return standardMessage;
        }

        public void setStandardMessage(String standardMessage) {
            this.standardMessage = standardMessage;
        }

    }
}